package com.faxsun.profile.core.domain;

import org.broadleafcommerce.core.order.domain.OrderItem;
import org.broadleafcommerce.core.order.domain.OrderItemImpl;
import org.broadleafcommerce.profile.core.domain.Customer;
import org.broadleafcommerce.profile.core.domain.CustomerImpl;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.math.BigDecimal;

/**
 * Created by Rongxin on 2015-07-08.
 */
@Entity
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "FS_REFERRAL_CUSTOMER_ORDER_ITEM_XREF")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE, region = "blCustomerElements")
public class FSReferralCustomerOrderItemXrefImpl implements FSReferralCustomerOrderItemXref {

    @Id
    @GeneratedValue(generator = "ReferralCustomerOrderItemXrefId")
    @GenericGenerator(
        name = "ReferralCustomerOrderItemXrefId",
        strategy = "org.broadleafcommerce.common.persistence.IdOverrideTableGenerator",
        parameters = {
            @org.hibernate.annotations.Parameter(name = "segment_value", value = "FSReferralCustomerOrderItemXrefImpl"),
            @org.hibernate.annotations.Parameter(name = "entity_name",
                value = "com.faxsun.profile.core.domain.FSReferralCustomerOrderItemXrefImpl")})
    @Column(name = "REFERRAL_CUSTOMER_ORDER_ITEM_ID")
    protected Long id;

    @ManyToOne(targetEntity = CustomerImpl.class, optional = false)
    @JoinColumn(name = "CUSTOMER_ID")
    protected Customer customer;

    @OneToOne(targetEntity = OrderItemImpl.class, optional = false)
    @JoinColumn(name = "ORDER_ITEM_ID")
    protected OrderItem orderItem;

    @Column(name = "REFERRAL_CREDIT")
    protected BigDecimal referralCredit;

    @Column(name = "REFERRAL_STATUS")
    @Enumerated(EnumType.STRING)
    protected FSReferralStatusEnum referralStatus;

    @Override
    public Long getId() {
        return id;
    }

    @Override
    public void setId(Long id) {
        this.id = id;
    }

    @Override
    public Customer getCustomer() {
        return customer;
    }

    @Override
    public void setCustomer(Customer customer) {
        this.customer = customer;
    }

    @Override
    public OrderItem getOrderItem() {
        return orderItem;
    }

    @Override
    public void setOrderItem(OrderItem orderItem) {
        this.orderItem = orderItem;
    }

    @Override
    public BigDecimal getReferralCredit() {
        return referralCredit;
    }

    @Override
    public void setReferralCredit(BigDecimal referralCredit) {
        this.referralCredit = referralCredit;
    }

    @Override
    public FSReferralStatusEnum getReferralStatus() {
        return referralStatus;
    }

    @Override
    public void setReferralStatus(FSReferralStatusEnum referralStatus) {
        this.referralStatus = referralStatus;
    }
}
